Learn R Programming

cols (version 1.5)

Constrained least squares: Constrained least squares

Description

Constrained least squares.

Usage

cls(y, x, R, ca)
mvcls(y, x, R, ca)

Value

A list including:

be

A numerical matrix with the constrained beta coefficients.

mse

A numerical vector with the mean squared error.

Arguments

y

The response variable. For the cls() a numerical vector with observations, but for the mvcls() a numerical matrix .

x

A matrix with independent variables, the design matrix.

R

The R vector that contains the values that will multiply the beta coefficients. See details and examples.

ca

The value of the constraint, \(R^T \beta = c\). See details and examples.

Author

Michail Tsagris.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.

Details

This is described in Chapter 8.2 of Hansen (2019). The idea is to inimise the sum of squares of the residuals under the constraint \(R^\top \bm{\beta} = c\). As mentioned above, be careful with the input you give in the x matrix and the R vector. The cls() function performs a single regression model, whereas the mcls() function performs a regression for each column of y. Each regression is independent of the others.

References

Hansen, B. E. (2022). Econometrics, Princeton University Press.

See Also

pls, int.cls

Examples

Run this code
x <- as.matrix( iris[1:50, 1:4] )
y <- rnorm(50)
R <- c(1, 1, 1, 1)
cls(y, x, R, 1)

Run the code above in your browser using DataLab